<template>

  <div>
     <!--  面包屑  -->
    <el-breadcrumb separator-class="el-icon-arrow-right" style="font-size: 16px;">
      <el-breadcrumb-item :to="{ path: '/' }">
        <i class="el-icon-s-promotion"></i> 后台管理
      </el-breadcrumb-item>
      <el-breadcrumb-item>供应商列表</el-breadcrumb-item>
      <el-breadcrumb-item v-for="item in history" :key="item.id"><span v-text="item.name"></span></el-breadcrumb-item>
    </el-breadcrumb>

     <!--  分割线  -->
    <el-divider></el-divider>

    <!--  表单数据  -->
    <el-table :data="tableData"  border style="width: 100%">

      <el-table-column label="操作" width="150" align="center">
        <template slot-scope="scope">
          <el-button type="danger" icon="el-icon-plus" circle size="mini"
                     :disabled="scope.row.isParent == 1"
                     @click="openDeleteConfirm(scope.row)"></el-button>
          <el-button type="primary" icon="el-icon-edit" circle size="mini"
                     @click="openEditDialog(scope.row)"></el-button>
          <el-button type="danger" icon="el-icon-delete" circle size="mini"
                     :disabled="scope.row.isParent == 1"
                     @click="openDeleteConfirm(scope.row)"></el-button>
        </template>
      </el-table-column>
      <el-table-column label="是否启用" width="80" align="center">
        <template slot-scope="scope">
          <el-switch
              v-model="scope.row.enable"
              @change="toggleEnable(scope.row)"
              :active-value="1"
              :inactive-value="0"
              active-color="#13ce66"
              inactive-color="#cccccc">
          </el-switch>
        </template>
      </el-table-column>
      <el-table-column prop="id" label="ID" width="60" align="center"></el-table-column>
      <el-table-column prop="supplier" label="名称" width="180" header-align="center"></el-table-column>
      <el-table-column prop="contacts" label="联系人" header-align="center"></el-table-column>
      <el-table-column prop="phonenum" label="电话" width="120" header-align="center"></el-table-column>
      <el-table-column prop="email" label="邮件" width="180" header-align="center"></el-table-column>
      <el-table-column prop="description" label="简介" width="200" header-align="center"></el-table-column>
      <el-table-column prop="address" label="地址" width="250" header-align="center"></el-table-column>
      <el-table-column prop="advanceIn" label="预收款" width="80" header-align="center"></el-table-column>
      <el-table-column prop="beginNeedGet" label="期初应收" width="80" header-align="center"></el-table-column>
      <el-table-column prop="beginNeedPay" label="期初应付" width="80" header-align="center"></el-table-column>
      <el-table-column prop="allNeedGet" label="累计应收" width="80" header-align="center"></el-table-column>
      <el-table-column prop="allNeedPay" label="累计应付" width="80" header-align="center"></el-table-column>

    </el-table>
  </div>

</template>

<script>
export default {
  data() {
    return {
      tableData: []
    }
  },
  methods: {
    loadSupplierList() {
      let url = 'http://localhost:8001/suppliers';
      console.log('url = ' + url);
      this.axios.get(url).then((response) => {
        let responseBody = response.data;
        if (responseBody.state == 20000) {
          this.tableData = responseBody.data
        }else {
          this.$message.error(responseBody.message);
        }
      });
    }
  },
  mounted() {
    this.loadSupplierList();
  }
}
</script>